package cn.edu.lingnan.service;

import cn.edu.lingnan.dao.*;
import cn.edu.lingnan.pojo.Score;

public class ScoreServiceMysqlImpl implements ScoreService{
    StudentDao studentDao=new StudentDaoMysqlImpl();
    ScoreDao scoreDao =new ScoreDaoMysqlImpl();
    CourseDao courseDao=new CourseDaoMysqlImpl();

    //新增一条分数记录:成功1  |   失败0 |找不到学生记录2   |找不到课程记录3
    public int insertScore(Score _score) {
        int flag =0;
        if (studentDao.findStudentBySid(_score.getSid()).getSid()==null) {
            return 2;
        }
        if (courseDao.findCourseByCid(_score.getCid()).getCid()==null) {
            return 3;
        }
        flag=scoreDao.insertScore(_score);

        return flag;
    }
}
